package org.cnbi.dao.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.cnbi.dao.INewsDao;
import org.cnbi.entity.News;
import org.cnbi.utils.pagination.PagingUtil;
import org.cnbi.utils.pojo.DynamicBean;
import org.cnbi.utils.pojo.Pagination;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Repository;

@Repository
public class INewsDaoImpl extends org.cnbi.dao.base.BaseDao implements INewsDao{

	@Override
	public List<Map> queryListMapBean(String sql, Object object) {
		List<DynamicBean> list = super.queryDynamicBeanList(sql, object);
		List<Map> resultList = new ArrayList<Map>();
		for (DynamicBean bean : list) {
			resultList.add(bean.getMap());
		}
		return resultList;
	}

	@Override
	public Pagination queryPagination(PagingUtil page, Object object) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean queryUserLicenseLastTimeWhetherPastdue(String sql) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public List<News> getAllNews(String sql, News news) throws Exception {
		SqlParameterSource ps=new BeanPropertySqlParameterSource(news); 
		return namedParameterJdbcTemplate.query(sql, ps, new BeanPropertyRowMapper(News.class)); 
	}


}
